package com.ler.springcloud.demo.controller.service.impl;

import com.ler.springcloud.demo.controller.service.HelloService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author lww
 * @date 2019-05-12 5:36 PM
 */
@Service
public class HelloServiceImpl implements HelloService {

	@Resource
	private RestTemplate restTemplate;

	@Override
	public String hiService(String name) {
		//在ribbon中会根据服务名来选择具体的服务实例，根据服务实例在请求的时候会用具体的url替换掉服务名
		String forObject = restTemplate.getForObject("http://SERVICE-HI/hi?name=" + name, String.class);
		return forObject;
	}
}
